<?php
class Commonmodel extends CI_Model{

public function __construct(){

        parent::__construct();
}

public function get_productcate(){
  $sql="select * from productcate";
   $query=$this->db->query($sql);
   $num=$query->num_rows();
   if($num>0){
      $arr=$query->result_array();
   }else{
      $arr=0;
   }
    return $arr;

}

public function get_brand(){
  $sql="select * from brand";
   $query=$this->db->query($sql);
   $num=$query->num_rows();
   if($num>0){
      $arr=$query->result_array();
   }else{
      $arr=0;
   }
    return $arr;

}


public function get_brandcate(){
  $sql="select * from brandcate";
   $query=$this->db->query($sql);
   $num=$query->num_rows();
   if($num>0){
      $arr=$query->result_array();
   }else{
      $arr=0;
   }
    return $arr;

}



public function get_navs(){
  $sql="select * from nav where parent='-1'";
   $query=$this->db->query($sql);
   $num=$query->num_rows();
   if($num>0){
      $arr=$query->result_array();
      foreach ($arr as $key => $value) {
         foreach ($value as $key2 => $value) {
           if($key2=="id"){
            $sql2="select * from nav where parent='$value'";

            $query2=$this->db->query($sql2);
            $num2=$query2->num_rows();
            if($num2>0){
              $arr[$key]['children']=$query2->result_array();
            }else{
              $arr[$key]['children']=0;
            }
           }
         }
      }
   }else{
      $arr=0;
   }
    return $arr;

}


public function get_adcate(){
  $sql="select * from adcate";
   $query=$this->db->query($sql);
   $num=$query->num_rows();
   if($num>0){
      $arr=$query->result_array();
   }else{
      $arr=0;
   }
    return $arr;

}



public function get_productnav(){
  $sql="select * from productnav";
   $query=$this->db->query($sql);
   $num=$query->num_rows();
   if($num>0){
      $arr=$query->result_array();
   }else{
      $arr=0;
   }
    return $arr;

}


public function get_products(){
  $sql="select * from point";
  $query=$this->db->query($sql);
  $arr=$query->result_array();
  return $arr;
}



}


?>
